﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Utils;
using WebAPIVue.Models;
using WebAPIVue.Models.InputValues;

namespace DAL
{
    public static class HerosDao
    {
        public static void AddHeros(List<PutHeroIn> heros)
        {
            StringBuilder TSQL = new StringBuilder();
            TSQL.Append(@"INSERT INTO Heros(`EName`,`CName`,`Type`,`Skin`)VALUES");
            foreach (var h in heros)
            {
                string inserSQL = string.Format(@"({0},'{1}','{2}','{3}'),",h.ename, h.cname, h.hero_type, h.skin_name);
                TSQL.Append(inserSQL);
            }
            string addSQL = TSQL.ToString().Trim(',');
            var lines = DataBaseUtility.Execute(addSQL);
        }

        public static List<Heros> GetHeros()
        {
            List<Heros> ls = new List<Heros>();
            string TSQL = string.Format(@"SELECT * FROM Heros");
            ls = DataBaseUtility.Query<Heros>(TSQL);
            return ls;
        }
    }
}
